home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / cug173.zip / BTOB.LXI < prev    next >
Text File  |  1980-01-01  |  1KB  |  53 lines

  1.  
  2. /*
  3.  * btob -- convert old b operators to new b form
  4.  */
  5. %{
  6. struct  maptab {
  7.         char    *old;
  8.         char    *new;
  9. }       maptab[] {
  10.         "=+",   "+=",
  11.         "=-",   "-=",
  12.         "=*",   "*=",
  13.         "=%",   "%=",
  14.         "=&",   "&=",
  15.         "=|",   "|=",
  16.         "=<<",  "<<=",
  17.         "=>>",  ">>=",
  18.         "=/",   "/=",
  19.         "=^",   "^=",
  20.         0,
  21. };
  22. struct  maptab  *mp;
  23. char    tbuf[10];
  24. char    *token();
  25.  
  26. main()
  27. {
  28.         while (yylex())
  29.                 ;
  30. }
  31. %}
  32. %%
  33.  
  34. "=" (<< | >> | "*" | + | - | "/" | "%" | "&" | "|" | "^") {
  35.         gettoken(tbuf, sizeof tbuf);
  36.         for (mp = maptab; mp->old; mp++)
  37.                 if (equal(tbuf, mp->old)) {
  38.                         printf("%s", mp->new);
  39.                         break;
  40.                 }
  41.         if (mp->old==0)
  42.                 fprintf(stderr, "error\n");
  43.         return(1);
  44. }
  45. [<=>!]"=" {
  46.    relat:
  47.         gettoken(tbuf, sizeof tbuf);
  48.         printf(tbuf);
  49. }
  50. "="[<>] {goto relat;}
  51. "=" / (++ | --) {printf("="); return(1);}
  52. [\0-\377]       {putchar(*token(NULL)); return(1);}
  53.